package com.sui.bigdata.flink.sql.function.table;

import com.sui.bigdata.flink.sql.function.scalar.NotBlank;

import org.apache.flink.table.functions.FunctionContext;
import org.apache.flink.table.functions.TableFunction;

/**
 * @Author yanjiantong
 * @Date 2019/12/2 13:59
 * @Description
 * @Reviewer
 */
public class SplitStringUdtf extends TableFunction<String> {

    @Override
    public void open(FunctionContext context) {
    }

    public void eval(String str,String splitSymbol) {
        if (NotBlank.eval(str) && splitSymbol != null) {
            String[] splits = str.split(splitSymbol);
            for (String split:splits) {
                if (!"".equals(split)){
                    collect(split);
                }
            }
        }
    }

    @Override
    public void close() {
    }

}
